package com.adinall.dsp.common.enums;

import java.util.ArrayList;
import java.util.List;

import com.adinall.dsp.core.data.KeyValueBean;

/**
 * 排序用常量
 * 
 * @author 高万超
 * @version V1.0.0 $ 2017年11月27日 下午2:19:44
 */
public enum Sort {

    ASC(0, "升序"),

    DESC(1, "降序");

    public final int code;

    public final String name;

    Sort(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String search(int code) {

        for (Sort e : values()) {

            if (e.code == code) {
                return e.name;
            }
        }

        return "";
    }

    public static List<KeyValueBean> list() {

        List<KeyValueBean> data = new ArrayList<>();

        for (Sort e : values()) {
            data.add(new KeyValueBean(e.code, e.name));
        }

        return data;
    }
}